package com.iflytek.uoamp.agent.logger;

import com.iflytek.uoamp.agent.core.agentinterface.IAgent;
import com.iflytek.uoamp.agent.logger.config.AgentLoggerConfig;
import com.iflytek.uoamp.agent.logger.reciver.LoggerServer;

import org.apache.log4j.Logger;

import java.io.IOException;
/**
 * @ClassName: AgentLoggerMain
 * @Description: 日志服务器初始化以及启动
 * @author qinanyuan
 * @date 2017年4月05日 下午9:08:47
 */
public class AgentLoggerMain implements IAgent {
    private static String LEVEL = "2"; 

    private static int port;

	
	/* (非 Javadoc)
	 * 
	 * 
	 * @see com.iflytek.uoamp.agent.core.agentServiceInterface.AgentServiceInterface#init()
	 */
	    
	@Override
	public void init() {
        try {
            AgentLoggerConfig.getInstance().init();
            port = AgentLoggerConfig.getInstance().getPort();
        } catch (IOException e) {
        	Logger.getRootLogger().error("initCoreData fail! The Exception is ："+ e);
        }
		
	}

	
	/* (非 Javadoc)
	 * 
	 * 
	 * @see com.iflytek.uoamp.agent.core.agentServiceInterface.AgentServiceInterface#start()
	 */
	    
	@Override
	public void start() {
		//开启日志服务器
		new LoggerServer(port).start();
		
	}

	
	/* (非 Javadoc)
	 * 
	 * 
	 * @return
	 * @see com.iflytek.uoamp.agent.core.agentServiceInterface.AgentServiceInterface#getPropertiy()
	 */
	    
	@Override
	public String getPropertiy() {
		return LEVEL;
	}
}
